#ifndef _VALIDATOR_H_
#define _VALIDATOR_H_

//@author A0083881W
#include "Task.h"
#include<iostream>
#include<fstream>
#include<string>
#include<cctype>
#include<vector>
#include<sstream>
#include<algorithm>
#include<math.h>
#include<ctime>
#include<assert.h>

using namespace std;

class Validator{
private:
        //a temporary vector used for storing temporary information. 
        vector<string> tempVector;
        //a temporary vector used for storing dates that needs to be validated. 
        vector<int> dateVector;
		static enum FREQUENCY_TYPE {WEEKLY, MONTHLY};
public:
        //vector<Task>taskList is a vector of 'Task' instances from the executorclass.
		bool isEmptyString(string sentence);
        bool isEmptyTaskList(vector<Task*> & taskList);
        bool isFileEmpty(fstream &storeFile);

        bool isInt(string input);
        bool isLeapYear(string year);
		bool isLowerCase(string input);

        bool isValidCommand(string command);
        bool isValidKeyword(string keyword);
		bool isValidFrequency(string frequency);
        bool isValidTask(string taskname, vector<Task*> & taskList);
        bool isValidTaskNumber(int tasknumber, vector<Task*> & taskList);
        bool isValidDate(string &date);
		bool isValidPostponeDate(string& current_date, string& postponed_date);
        bool isValidDay(int day, int month, string year);
        bool isValidMonth(int day, int month, string year);
        bool isValidYear(string year);
        bool isValidTaskName(string taskname);
        //This function checks if the task's start time and end time is not past the current time.
        bool isValidTaskTime(string &time, string date);
        bool isNotPastDeadLine(string date);

		bool isValidTimeRange(string &time);
		bool isValidTimeDeadline(string time, string date);

        // the next 3 functions help to ensure that the date is in the right format:dd/mm/yyyy
        /*if not the functions will help to do so. eg if the user types in 12. 12 is assumed be the
        day and the functions will add in the CURRENT MONTH and CURRENT YEAR. if the user types in 12/03,
        then the functions will add in the CURRENT YEAR.
        */
		string makeProperMonthFormat(string date);
		string makeProperDayFormat(string date);
        string makeProperDateFormat(string date);

		string addMonthAndYear(string date);
        string addYear(string date); 
        string addStringToString(string originalstring, string addstring);
		FREQUENCY_TYPE determineFrequencyType(string frequency);
		string toLowerCase(string input);
		string getYear();
		string getCurrentDate();
        string formatTime(string time);
		string changeIntToString(int integer);
		string getMonthOfYear(string date);
		string getMonthString(int month);
		string getRepeatYear(string year);
		string whenNoMoreDate(string date, string frequency);
		string noFurther(string frequency);
		string noFurtherIn(string frequency);
		vector<string> repeatMode(string date,string frequency);
		vector<string> getWeeklyDates(int day, int month, string year);
		vector<string> getMonthlyDates(int day, int month, string year);
		      
        int getDay();
        int getMonth();
        int getCurrentMonth();
        int getCurrentYear();
        int getCurrentHour();
        int getCurrentMinute();
        int getCurrentDay();

		void tokenizeDate(string date);
		void changeStringToInt();
        void clearVectors();
        void clearTempVector();

		tm getCurrentTimeInfo();
};
#endif